/*
 * Created on Jun 24, 2005
 */
package org.vectrics.recruiter.job.event;

import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

import org.apache.log4j.Logger;
import org.vectrics.event.Event;
import org.vectrics.event.EventEmailBuilder;
import org.vectrics.event.EventHandler;
import org.vectrics.recruiter.job.JobCandidate;

/**
 * @author MMoore
 */
public class JobCandidateStatusEventHandler extends EventHandler {
	private transient Logger log = Logger.getLogger(this.getClass());
	private JobCandidate jobCandidate = null;
	
	/**
	 * Constructor 
	 */
	public JobCandidateStatusEventHandler() {
		super();
	}
	
	protected EventEmailBuilder getEmailBuilder(Event event, Locale locale) {
		return(new JobCandidateEmailBuilder(event, this.jobCandidate, locale));
	}
	
	protected void doHandleEvent(Event event) {
		log.debug("doHandleEvent(Event event) called");
		this.jobCandidate = (JobCandidate)event.getAttachments().iterator().next();
	}
	
	protected Set findNotifyPersons() {
		Set notifyPersons = new HashSet();
		
		if (this.jobCandidate.getJob().getPrimaryRecruiter() != null)
			notifyPersons.add(this.jobCandidate.getJob().getPrimaryRecruiter());
		if (this.jobCandidate.getJob().getSecondaryRecruiter() != null)
			notifyPersons.add(this.jobCandidate.getJob().getSecondaryRecruiter());
		if (this.jobCandidate.getJob().getHiringManager() != null)
			notifyPersons.add(this.jobCandidate.getJob().getHiringManager());
		
		return(notifyPersons);
	}
	

}
